
<%@ page language="java" import="java.util.*" pageEncoding="utf-8"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/functions" prefix="fn"%>
<%@ taglib prefix="codec" uri="/WEB-INF/tld/codec.tld"%>
<%@ include file="/WEB-INF/common/taglibs.jsp"%>
<script type="text/javascript" src="${ctx}/resources/js/datatable-query.js"></script>
<div class="row-fluid">
		<div class="span12">
			<div class="box gradient">
				<div class="title">
					<h4><span>Payment Config</span>
					<span class="box-form right">
 			 		<a href="#"  id="reload" class="btn btn-mini">Reload</a>
 						</span>
					</h4>
					<a href="#" class="minimize">Minimize</a>
				</div>
				<div class="content scrollable clearfix">
					<table class="ajaxTable display table table-bordered">
						<thead>
							<tr>
								<th><a id="select_all"><span class="icomoon-icon-checkmark-2"></span></a></th>
								<th>Payment </th>
								<th>Key</th>
								<th>Value </th>
								<th>Action</th>
							</tr>
						</thead>
					</table>
				</div>
			</div>
			
</div>
</div> 

<script type="text/javascript">
$(document).ready(function () {
	
	$("#reload").click(function() {

		$.ajax({
			url : "${ctx}/admin/payment-config/reload/",
			type : "POST",
			data : {
				"_method" : "PUT"
			},
			dataType : "json",
			success : function(data) {
				if (data.state && data.state.indexOf("SUCCESS") != -1) {
					johnny.success("reload setting successfully");
					return;
				}
 
			}
		});

		return false;
	});
	
	
	johnny.oTable = $('.ajaxTable').dataTable({
		"bLengthChange": true,
		"aoColumnDefs" : [ {
			'bSortable' : false,
			'aTargets' : [ 0,4 ]
		} ],
		"sAjaxSource": '${ctx}/admin/payment-config/',
		"fnInitComplete": function (oSettings, json) { }
	});
	var name = $("<input>").attr({
		type: "text",
		field: "name",
		op: "cn",
		placeholder: "Group Name",
		class: "filterdata"
	});
	johnny.initTableQuery(name);
	var config = {
			id : 'del',
			text  : 'Del',
			domain : "Banner",
			operation : "Delete",
			url : "${ctx}/admin/banner-group/del/"
	};
//	johnny.tableBtn(config);
	});


var columnHeader = ['','paymentGateway.id', 'name', 'value',''];
var QueryData = function (aoData) {
	return johnny.initQueryData(aoData, columnHeader);
}

var DataTableForm = function (json, echo) {
	var dataArray = new Array();
	for (var i = 0; i < json.result.length; i++) {
		var subArray = new Array();
		var value = johnny.getForSelect(json.result[i].id);
 		subArray.push(value);
		var link = "${ctx}/admin/payment-config/"+json.result[i].id+"/edit/";
		subArray.push(json.result[i].paymentGateway.name);
 		subArray.push(json.result[i].name);
		subArray.push(json.result[i].value);
		subArray.push(johnny.getEditHtml(link));
		dataArray.push(subArray);
	}
	return {
		sEcho: echo,
		iTotalRecords: json.totalCount,
		iTotalDisplayRecords: json.totalCount,
		aaData: dataArray
	};
}
</script>